<?php $dateCurrent = ''; ?>
<?php if( $calendars == null ): ?>
		<div class="category_title">
			<?php if( $dateStart == $dateEnd ):?>
				<?php echo $dateStart . ' ' . __('no events')?>
			<?php else:?>
				<?php echo __('from') . ' ' . $dateStart . ' ' . __('to') . ' ' . $dateEnd . ' ' . __('no events')?>
			<?php endif;?>
		</div>
<?php else:?>		
	<?php //debugvar($calendars, 'calendars');?>
		<div class="category_title">
			<?php if( $dateStart == $dateEnd ):?>
				<?php echo __('events') . ' ' . $dateStart ?>
			<?php else:?>
				<?php echo __('events') . ' ' . __('from') . ' ' . $dateStart . ' ' . __('to') . ' ' . $dateEnd ?>
			<?php endif;?>
		</div>

    <div class="center_content">
        <?php $i = -1; ?>
		<?php foreach( $calendars as $calendar ):	?>
            <?php $i++; ?>
            <div class="event_item<?php echo ((($i)%2 == 0)?'':'2')?>">
            <?php if( $dateCurrent != substr($calendar->getStartAt(), 0, 10) ): ?>
                    <?php $dateCurrent = substr($calendar->getStartAt(), 0, 10) ?>
                    <div class="event_date">
                        <?php echo link_to(
                                    substr($calendar->getStartAt(), 0, 10)
                                    , 'calendar/show/?id=' . $calendar->getId()
                                ) ?>
                    </div>
                <?php else: ?>
                    <div class="event_date">
                        ---
                    </div>
            <?php endif; ?>

					<div>
						<div class="event_title">
							<?php echo link_to(
                                        $calendar->getTitle()
                                        , 'calendar/show/?id=' . $calendar->getId()
                                    ) ?>
						</div>

                        <?php if( $sf_user->isAuthenticated() == true && $sf_user->hasCredential('Admin') ): ?>
                                <div class="edit">
                                    <?php echo link_to(
                                                    image_tag(
                                                                'pencil.png'
                                                                , array('style' => 'border:0px;')
                                                            )
                                                    , 'calendar/edit/?id=' . $calendar->getId()
                                                    , array()) ?>
                                </div>
                        <?php endif; ?>

					</div>
                    <div style="clear: both;"></div>
            </div>
		<?php endforeach; ?>
    </div>

<?php endif;?>